package com.tms.app.tms.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.alibaba.sdk.android.ams.common.util.StringUtil;
import com.tms.app.tms.app.Constant;
import com.tms.app.tms.ui.base.ui.BaseListActivity;
import com.tms.app.tms.ui.home.MainActivity;
import com.tms.app.tms.ui.login.LoginAt;
import com.tms.app.tms.utils.SharePreferenceUtil;

import org.xutils.http.RequestParams;

/**
 * Created by Administrator on 2018/3/12 0012.
 */

public class AutoLoginActivity extends BaseListActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        autoLogin();
    }

    private void autoLogin() {
        String token = SharePreferenceUtil.getToken(this);
        if (!StringUtil.isEmpty(token)&&token.length()>5){
            startActivity(new Intent(this,MainActivity.class));
        }else {
            startActivity(new Intent(this,LoginAt.class));
        }
        finish();

    }

    private void doAutoLogin() {
        String token = SharePreferenceUtil.getToken(this);
        if (!StringUtil.isEmpty(token)){}


        if ((System.currentTimeMillis() - mExitTime) < 2000) {
            mExitTime = System.currentTimeMillis();
            return;
        }

        RequestParams params=new RequestParams(Constant.AUTO_LOGIN);
        params.addBodyParameter("token", SharePreferenceUtil.getString(this,"token",""));
       // presenter.getObjectFromServer(params);
        showLoadingDialog();
    }

}
